//万昱柔 2025/3/10
import { MaxScore } from "./Common";
cc.Class({
    extends: cc.Component,

    properties: {
        button_menu: cc.Button,
        levelSpr: cc.Sprite,
        curLabel: cc.Label,
        maxLabel: cc.Label,
        medals: [cc.SpriteFrame],
        levelData: cc.JsonAsset
    },

    onLoad() {
        this.button_menu.node.on('click', () => {
            cc.director.loadScene("Menu")
        }, this);
        this.initInfo();
    },



    start() {

    },
    initInfo() {
        this.curLabel.string = cc.curScore;
        this.maxLabel.string = cc.sys.localStorage.getItem(MaxScore);
        for (let i = this.levelData.json.length - 1; i > 0; i--) {
            const data = this.levelData.json[i]
            console.log(this.medals[i]);

            if (cc.curScore >= data.minScore) {
                this.levelSpr.spriteFrame = this.medals[i];
                break;
            }

        }
    },

    //update(dt) { },
});
